#!/usr/bin/python

import sys
import numpy

def check_line( input_string, atom_name="H" ):
    """
    
    Check the input_string for atoms with atom_name
        
    """
    if input_string.startswith("ATOM") and atom_name in line.split():
        return input_string

    return ""

x_values=[]
y_values=[]
z_values=[]

if len(sys.argv) > 1:
    filename=sys.argv[1]
    buffer = open( filename, "r" )
else:
    buffer=sys.stdin

text_lines = buffer.readlines()

for line in text_lines:
    if not check_line(line) == "":
        line_split=line.split()
        x_values.append(float(line_split[4]))
        y_values.append(float(line_split[5]))
        z_values.append(float(line_split[6]))

print "The values are:"
x_avg = numpy.mean(x_values)
y_avg = numpy.mean(y_values)
z_avg = numpy.mean(z_values)

print x_avg
print y_avg
print z_avg
